package com.xidian.GMS.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xidian.GMS.dto.Page;
import com.xidian.GMS.entity.EmploymentConsult;
import com.xidian.GMS.service.EmploymentConsultService;

@Controller
public class EmploymentConsultController {

	@Autowired
	 private EmploymentConsultService  employmentConsultService;
	
	
	@RequestMapping(value="/EmploymentConsultEdit",method= RequestMethod.GET)
	public String update0(int consultantid ,Model  model){
		    model.addAttribute("consultantid", consultantid);
			return "EmploymentConsultEdit";
			// TODO: handle exception
		
	}


	@RequestMapping(value="/EmploymentConsultEdit",method= RequestMethod.POST)
	public String update(EmploymentConsult employmentConsult){
		
		employmentConsultService.update(employmentConsult);
		
			return "EmploymentConsultIndex";
	}
	
	

	@RequestMapping(value="/EmploymentConsultInsert",method= RequestMethod.POST)
	public String Insert(EmploymentConsult employmentConsult){
		
		try {		
		    employmentConsultService.Insert( employmentConsult);
			return "EmploymentConsultIndex";
		} catch (Exception e) {
			return "EmploymentConsultInsert";
			// TODO: handle exception
		}
		
	}
	@RequestMapping(value="/EmploymentConsultInsert",method= RequestMethod.GET)
	public String Insert(){

			return "EmploymentConsultInsert";
			// TODO: handle exception
		
		
	}
	@RequestMapping(value="/EmploymentConsult",method= RequestMethod.GET)
	public String Insert22(){

			return "EmploymentConsult";
			// TODO: handle exception
		
		
	}
	@RequestMapping(value="/EmploymentConsultDelete",method= RequestMethod.GET)
	public String delete(int consultantid){
		try {
			employmentConsultService.delete(consultantid);
			return "forward:/fun6-employmentConsult.html";
		} catch (Exception e) {
			return "EmploymentConsultInsert";
			// TODO: handle exception
		}
		
	}

	@RequestMapping(value="/EmploymentConsultIndex",method= RequestMethod.POST)
	public String IndexPost(){

			return "EmploymentConsultIndex";
			// TODO: handle exception
		}
		

	@RequestMapping(value="/EmploymentConsultIndex",method= RequestMethod.GET)
	@ResponseBody
	public Page index(@RequestParam(name="cur", defaultValue="1") int cur, Model model){
		Page page = employmentConsultService.getEmploymentConsult(cur);
		System.out.println(page);
	 	model.addAttribute("page", page);
	 	
			return page;
			// TODO: handle exception
		
		
	}

}
